package com.cz.mes.view;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;

import java.io.File;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ColumnUpdate {
    public static void main(String[] args) {
        try {
            String dbGroup = "uat3";

            List<Entity> entityList = Db.use(dbGroup).query("select * from mes_vw_column where table_id = 8");
            System.out.println(entityList.size());

            entityList.forEach(entity -> {
                int id = entity.getInt("id");
                String dbColumnName = entity.getStr("db_column_name");
                // String newDbColumnName = StrUtil.toCamelCase(dbColumnName);
                String newDbColumnName =  StrUtil.toUnderlineCase(dbColumnName);
                try {
                    Db.use(dbGroup).execute("update mes_vw_column set db_column_name =? where id =?", newDbColumnName, id);
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            });
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
